<template>
    <view class="container">
        <view class="progress">
            <view class="item-a">
                <van-steps :steps="steps" :active="active" :active-icon="activeIcon" :active-color="activeColor" />
            </view>
            <view class="item-c" v-if="groupon.status === 1">
                <view class="l">
                    开团还缺
                    <van-tag type="danger">{{ rules.discountMember - joiners.length }}</van-tag>
                    人
                </view>
                <view class="r">
                    <button class="btn active" open-type="share">邀请参团</button>
                </view>
            </view>
        </view>

        <view class="menu-list-pro">
            <view class="h">
                <view class="label">参与团购 ( {{ joiners.length }}人)</view>
                <view class="status">查看全部</view>
            </view>
            <view class="menu-list-item" :data-id="item.id" v-for="(item, index) in joiners" :key="index">
                <image class="icon" :src="item.avatar"></image>

                <text class="txt">{{ item.nickname }}</text>
            </view>
        </view>

        <view class="order-goods">
            <view class="h">
                <view class="label">商品信息</view>
            </view>
            <view class="goods">
                <view class="item" v-for="(item, index) in orderGoods" :key="index">
                    <view class="img">
                        <image :src="item.picUrl"></image>
                    </view>

                    <view class="info">
                        <view class="t">
                            <text class="name">{{ item.goodsName }}</text>
                            <text class="number">x{{ item.number }}</text>
                        </view>
                        <view class="attr">{{ item.goodsSpecificationValues }}</view>
                        <view class="price">￥{{ item.retailPrice }}</view>
                    </view>
                </view>
            </view>

            <view class="order-bottom">
                <view class="total">
                    <view class="t">
                        <text class="label">商品合计：</text>
                        <text class="txt">￥{{ orderInfo.goodsPrice }}</text>
                    </view>
                    <view class="t">
                        <text class="label">商品运费：</text>
                        <text class="txt">￥{{ orderInfo.freightPrice }}</text>
                    </view>
                </view>
                <view class="pay-fee">
                    <text class="label">商品实付：</text>
                    <text class="txt">￥{{ orderInfo.actualPrice }}</text>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
export default {
    data() {
        return {
            id: 0,
            groupon: {
                status: 0
            },
            joiners: [],
            orderInfo: {
                goodsPrice: '',
                freightPrice: '',
                actualPrice: ''
            },
            orderGoods: [],
            rules: {
                discountMember: 0
            },
            active: 0,
            steps: [],
            activeIcon: '',
            activeColor: ''
        };
    },
    onLoad: function (options) {
        // 页面初始化 options为页面跳转所带来的参数
        this.setData({
            id: options.id
        });
        this.getOrderDetail();
    },
    // 页面分享
    onShareAppMessage: function () {
        let that = this;
        return {
            title: '邀请团购',
            desc: '唯爱与美食不可辜负',
            path: '/pages/index/index?grouponId=' + this.id
        };
    },
    onReady: function () {
        // 页面渲染完成
    },
    onShow: function () {
        // 页面显示
    },
    onHide: function () {
        // 页面隐藏
    },
    onUnload: function () {
        // 页面关闭
    },
    methods: {
        getOrderDetail: function () {
            let that = this;
            util.request(api.GroupOnDetail, {
                grouponId: that.id
            }).then(function (res) {
                if (res.errno === 0) {
                    let _steps = [
                        {
                            text: '已开团'
                        },
                        {
                            text: '开团中'
                        },
                        {
                            text: '开团成功'
                        }
                    ];
                    let _active = res.data.groupon.status;
                    let _activeIcon = 'success';
                    let _activeColor = '#07c160';
                    if (res.data.groupon.status === 3) {
                        _steps = [
                            {
                                text: '已开团'
                            },
                            {
                                text: '开团中'
                            },
                            {
                                text: '开团失败'
                            }
                        ];
                        _active = 2;
                        _activeIcon = 'fail';
                        _activeColor = '#EE0A24';
                    }
                    that.setData({
                        joiners: res.data.joiners,
                        groupon: res.data.groupon,
                        orderInfo: res.data.orderInfo,
                        orderGoods: res.data.orderGoods,
                        rules: res.data.rules,
                        active: _active,
                        steps: _steps,
                        activeIcon: _activeIcon,
                        activeColor: _activeColor
                    });
                }
            });
        }
    }
};
</script>
<style>
page {
    height: 100%;
    width: 100%;
    background: #f4f4f4;
}

.progress {
    padding-top: 25rpx;
    background: #fff;
    height: auto;
    overflow: hidden;
}

.item-a {
    padding: 0 21.25rpx;
}

.item-c {
    margin-left: 31.25rpx;
    height: 103rpx;
    line-height: 103rpx;
}

.item-c .l {
    float: left;
}

.item-c .r {
    height: 103rpx;
    float: right;
    display: flex;
    align-items: center;
    padding-right: 16rpx;
}

.item-c .btn {
    float: right;
    line-height: 66rpx;
    font-size: 30rpx;
    border-radius: 5rpx;
    text-align: center;
    margin: 0 15rpx;
    padding: 0 20rpx;
    height: 66rpx;
}

.item-c .btn.active {
    background: #a78845;
    color: #fff;
}

.order-goods {
    margin-top: 20rpx;
    background: #fff;
}

.order-goods .h {
    height: 93.75rpx;
    line-height: 93.75rpx;
    margin-left: 31.25rpx;
    border-bottom: 1px solid #f4f4f4;
    padding-right: 31.25rpx;
}

.order-goods .h .label {
    float: left;
    font-size: 30rpx;
    color: #333;
}

.order-goods .h .status {
    float: right;
    font-size: 30rpx;
    color: #b4282d;
}

.order-goods .item {
    display: flex;
    align-items: center;
    height: 192rpx;
    margin-left: 31.25rpx;
    padding-right: 31.25rpx;
    border-bottom: 1px solid #f4f4f4;
}

.order-goods .item:last-child {
    border-bottom: none;
}

.order-goods .item .img {
    height: 145.83rpx;
    width: 145.83rpx;
    background: #f4f4f4;
}

.order-goods .item .img image {
    height: 145.83rpx;
    width: 145.83rpx;
}

.order-goods .item .info {
    flex: 1;
    height: 145.83rpx;
    margin-left: 20rpx;
}

.order-goods .item .t {
    margin-top: 8rpx;
    height: 33rpx;
    line-height: 33rpx;
    margin-bottom: 10.5rpx;
}

.order-goods .item .t .name {
    display: block;
    float: left;
    height: 33rpx;
    line-height: 33rpx;
    color: #333;
    font-size: 30rpx;
}

.order-goods .item .t .number {
    display: block;
    float: right;
    height: 33rpx;
    text-align: right;
    line-height: 33rpx;
    color: #333;
    font-size: 30rpx;
}

.order-goods .item .attr {
    height: 29rpx;
    line-height: 29rpx;
    color: #666;
    margin-bottom: 25rpx;
    font-size: 25rpx;
}

.order-goods .item .price {
    display: block;
    float: left;
    height: 30rpx;
    line-height: 30rpx;
    color: #333;
    font-size: 30rpx;
}

.order-goods .item .btn {
    height: 50rpx;
    line-height: 50rpx;
    border-radius: 5rpx;
    text-align: center;
    display: block;
    float: right;
    margin: 0 15rpx;
    padding: 0 20rpx;
}

.order-goods .item .btn.active {
    background: #b4282d;
    color: #fff;
}

.order-bottom {
    margin-top: 20rpx;
    padding-left: 31.25rpx;
    height: auto;
    overflow: hidden;
    background: #fff;
}

.order-bottom .address {
    height: 128rpx;
    padding-top: 25rpx;
    border-bottom: 1px solid #f4f4f4;
}

.order-bottom .address .t {
    height: 35rpx;
    line-height: 35rpx;
    margin-bottom: 7.5rpx;
}

.order-bottom .address .name {
    display: inline-block;
    height: 35rpx;
    width: 140rpx;
    line-height: 35rpx;
    font-size: 30rpx;
}

.order-bottom .address .mobile {
    display: inline-block;
    height: 35rpx;
    line-height: 35rpx;
    font-size: 30rpx;
}

.order-bottom .address .b {
    height: 35rpx;
    line-height: 35rpx;
    font-size: 30rpx;
}

.order-bottom .total {
    height: 106rpx;
    padding-top: 20rpx;
    border-bottom: 1px solid #f4f4f4;
}

.order-bottom .total .t {
    height: 30rpx;
    line-height: 30rpx;
    margin-bottom: 7.5rpx;
}

.order-bottom .total .t .label {
    width: 150rpx;
    height: 35rpx;
    line-height: 35rpx;
    font-size: 30rpx;
}

.order-bottom .total .t .txt {
    float: right;
    height: 35rpx;
    line-height: 35rpx;
    font-size: 30rpx;
    padding-right: 31.25rpx;
}

.order-bottom .pay-fee {
    height: 81rpx;
    line-height: 81rpx;
}

.order-bottom .pay-fee .label {
    width: 140rpx;
}

.order-bottom .pay-fee .txt {
    float: right;
    padding-right: 31.25rpx;
}

.menu-list-pro {
    margin-top: 20rpx;
    overflow-x: scroll;
    white-space: nowrap;
    text-overflow: ellipsis;
    height: 260rpx;
    width: 100%;
    overflow: hidden;
    border-bottom: 1rpx #cfc9ca;
    background-color: #fff;
}

.menu-list-pro .h {
    height: 93.75rpx;
    line-height: 93.75rpx;
    margin-left: 31.25rpx;
    border-bottom: 1px solid #f4f4f4;
    padding-right: 31.25rpx;
}

.menu-list-pro .h .label {
    float: left;
    font-size: 30rpx;
    color: #333;
}

.menu-list-pro .h .status {
    float: right;
    font-size: 30rpx;
    color: #a78845;
}

.menu-list-pro .menu-list-item {
    display: block;
    float: left;
    height: 110rpx;
    width: 80rpx;
    margin-top: 30rpx;
    margin-bottom: 30rpx;
    margin-left: 40rpx;
}

.menu-list-pro .icon {
    height: 80rpx;
    width: 80rpx;
    border-radius: 12rpx;
    box-shadow: 0px 4rpx 4rpx 0px #cfc9ca;
}

.menu-list-pro .txt {
    display: block;
    float: left;
    width: 80rpx;
    margin-top: 5rpx;
    font-size: 22rpx;
    color: #a78845;
}
</style>
